<?php
function my_autoloader($class) {
    //var_dump($class);
    include $class . '.php';
}
spl_autoload_register('my_autoloader');


//创建一个Army对象
$main_army = new Army();

//添加一些Unit对象
$main_army->addUnit( new Archer() );
$main_army->addUnit( new LaserCanonUnit() );


//创建一个新的Army对象
$sub_army  =  new Army();
//添加一些Unit对象
$sub_army->addUnit( new Archer());
$sub_army->addUnit( new Archer());
$sub_army->addUnit( new Archer());


//把第二个Army对象添加到第一个Army对象中去
$main_army->addUnit($sub_army);

//所有的攻击强度计算都在幕后进行
print "main_army 攻击强度：{$main_army->bombardStrength()}\n<BR />";
print "sub_army 攻击强度：{$sub_army->bombardStrength()}\n<BR />";